package cn.bugstack.domain.trade.service.lock.factory;

import cn.bugstack.domain.trade.model.entity.GroupBuyActivityEntity;
import cn.bugstack.domain.trade.model.entity.TradeLockRuleCommandEntity;
import cn.bugstack.domain.trade.model.entity.TradeLockRuleFilterBackEntity;
import cn.bugstack.domain.trade.service.lock.filter.ActivityUsabilityRUleFilter;
import cn.bugstack.domain.trade.service.lock.filter.UserTakeLimitRuleFilter;
import cn.bugstack.types.design.framework.link.model2.LinkArmory;
import cn.bugstack.types.design.framework.link.model2.chain.BusinessLinkedList;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class TradeLockRuleFliterFactory {

    @Bean("tradeRuleFilter")
    public BusinessLinkedList<TradeLockRuleCommandEntity, TradeLockRuleFliterFactory.DynamicContext, TradeLockRuleFilterBackEntity>
    tradeRuleFilter(ActivityUsabilityRUleFilter activityUsabilityRUleFilter, UserTakeLimitRuleFilter userTakeLimitRuleFilter) {
        // 组装链的过程
        LinkArmory<TradeLockRuleCommandEntity, TradeLockRuleFliterFactory.DynamicContext, TradeLockRuleFilterBackEntity>  linkArmory =
                new LinkArmory<>("交易规则过滤连",activityUsabilityRUleFilter,userTakeLimitRuleFilter);
        return linkArmory.getLogicLink();
    }


    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class DynamicContext{// 不好维护的信息又可以串联上下节点。方便到不同节点调用
        private GroupBuyActivityEntity groupBuyActivity;
    }
}
